import { GCellRenderer } from "../../../../com/mui/controls/GCellRenderer";
import { ObjCreate } from "../common/ObjCreate";
import { GTextFormat } from "../../../common/GTextFormat";
import { ColorConfig } from "../../resource/ColorConfig";
import { ImagesConst } from "../../resource/ImagesConst";
import { BaseItem } from "../common/BaseItem";
import { Language } from "../../../../extend/language/Language";
import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { ResFileConst } from "../../resource/ResFileConst";
import { DayAndAccumulateRenderInfo } from "./DayAndAccumulateRenderInfo";
import { ItemData } from "../../resource/info/ItemData";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { EHolidayRetGiftBagStatus } from "../../../../Message/Public/EHolidayRetGiftBagStatus";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { GButton } from "../../../../com/mui/controls/GButton";
import { ScaleBitmap } from "../../../../com/mui/display/ScaleBitmap";
//class DayAnadAccumulateRender
    
    export  class DayAnadAccumulateRender extends GCellRenderer
    {
        constructor()
        {
            super();
            return;
        }

        protected /* override */ configUI(): void
        {
            super.configUI();
            this._bg = ObjCreate.createBitmap("", 0, 0, this);
            var loc1=new GTextFormat("", 12, ColorConfig.instance.getItemColor(4).intColor, true, null, null, null, null, flash.text.TextFormatAlign.CENTER);
            this._nameTxt = ObjCreate.createTextField("", 1, 10, 104, 20, this, loc1);
            this._itemBg = ObjCreate.createBg(21, 38, 64, 64, this, ImagesConst.PackItemBg);
            this._baseItem = new BaseItem();
            this._baseItem.move(23, 40);
            this._baseItem.setSize(60, 60);
            this._baseItem.isDragAble = false;
            this._baseItem.isDropAble = false;
            addChild(this._baseItem);
            this._getBtn = ObjCreate.createGButton(Language.getString(20146), 30, 107, 50, 25, this, "ButtonRed");
            this._getBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onGetBtnClickHandler);
            this._getBtn.enabled = false;
            this._getBtn.drawNow();
            LoaderHelp.addResCallBack(ResFileConst.DayAndAccumulateRecharge, this.onLoadBmResource);
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            super.data = arg1;
            this._newInfo = arg1 as DayAndAccumulateRenderInfo;
            if (this._newInfo) 
            {
                loc1 = new ItemData(this._newInfo.giftItemCode);
                if (loc1 && !(loc1 == ItemData.nullItemData)) 
                {
                    loc2 = ColorConfig.instance.getItemColor(loc1.itemInfo.item.color);
                    if (loc2) 
                    {
                        loc3 = loc2.color;
                    }
                    this._nameTxt.htmlText = HTMLUtil.addColor(loc1.itemInfo.item.name, loc3);
                    this._baseItem.itemData = loc1;
                }
                if (this._newInfo.giftState != EHolidayRetGiftBagStatus._EHolidayRetGiftBagUnavailable) 
                {
                    if (this._newInfo.giftState != EHolidayRetGiftBagStatus._EHolidayRetGiftBagAvailable) 
                    {
                        if (this._newInfo.giftState == EHolidayRetGiftBagStatus._EHolidayRetGiftBagHadGot) 
                        {
                            this._getBtn.label = Language.getString(74006);
                            this._getBtn.enabled = false;
                            this._getBtn.filters = [FilterConst.colorFilter];
                        }
                    }
                    else 
                    {
                        this._getBtn.label = Language.getString(74005);
                        this._getBtn.enabled = true;
                        this._getBtn.filters = [];
                    }
                }
                else 
                {
                    this._getBtn.label = Language.getString(74004);
                    this._getBtn.enabled = false;
                    this._getBtn.filters = [FilterConst.colorFilter];
                }
                this._getBtn.drawNow();
            }
            return;
        }

        /* internal  */onGetBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._baseItem.itemData) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.goGetDayRechargeGift, this._newInfo));
            }
            return;
        }

        public /* override */ set selected(arg1: Boolean)
        {
            super.selected = arg1;
            if (this._gradientGlow == null) 
            {
                this._gradientGlow = new Object /* flash.filters.GradientGlowFilter */();
                this._gradientGlow.distance = 0;
                this._gradientGlow.angle = 45;
                this._gradientGlow.colors = [16777062, 16776960];
                this._gradientGlow.alphas = [0, 1];
                this._gradientGlow.ratios = [0, 255];
                this._gradientGlow.blurX = 5;
                this._gradientGlow.blurY = 5;
                this._gradientGlow.strength = 2;
                this._gradientGlow.quality = flash.filters.BitmapFilterQuality.HIGH;
                this._gradientGlow.type = flash.filters.BitmapFilterType.OUTER;
            }
            if (arg1) 
            {
                this._bg.filters = [this._gradientGlow];
                mouseChildren = true;
            }
            else 
            {
                this._bg.filters = [];
            }
            return;
        }

        /* internal  */onLoadBmResource(): void
        {
            this._bg.bitmapData = GlobalClass.getBitmapData(ImagesConst.DAABG);
            return;
        }

        /* internal */ /* var */_bg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_nameTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_baseItem: BaseItem;

        /* internal */ /* var */_getBtn: GButton;

        /* internal */ /* var */_itemBg: ScaleBitmap;

        /* internal */ /* var */_newInfo: DayAndAccumulateRenderInfo;

        /* internal */ /* var */_gradientGlow: Object /* flash.filters.GradientGlowFilter */;
    }
